IF exists(SELECT * FROM dbo.sysobjects WHERE name='prognoseTotalen4' AND xtype='V') 
BEGIN
	DROP VIEW prognoseTotalen4
END
GO

create view prognoseTotalen4
as
select l.klas, k.studieKeuzePrognose, Sum(1) AS hetAantal
from leerlingen as l 
	left join keuzeteksten4 as k 
	  on l.inschrijvingsNr = k.inschrijvingsNr
group by l.klas, k.studieKeuzePrognose